package com.yunyi.system.service.impl;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import com.yunyi.common.core.domain.AjaxResult;
import com.yunyi.common.core.domain.entity.SysDoctorinfo;
import com.yunyi.system.domain.ConsultationStatisticsRequest;
import com.yunyi.system.service.SysDoctorinfoService;
import com.yunyi.system.mapper.SysDoctorinfoMapper;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
* @author Sekiro
* @description 针对表【sys_doctorinfo(医生信息表)】的数据库操作Service实现
* @createDate 2023-09-14 15:26:00
*/
@Service
public class SysDoctorinfoServiceImpl extends ServiceImpl<SysDoctorinfoMapper, SysDoctorinfo>
    implements SysDoctorinfoService{

    @Resource
    private SysDoctorinfoMapper doctorinfoMapper;

    @Override
    public AjaxResult consultationStatistics(ConsultationStatisticsRequest request) {
        boolean empty = request.getDateRange() == null || request.getDateRange().isEmpty();
        PageHelper.startPage(request.getPageNum(),request.getPageSize());
        List<SysDoctorinfo> sysDoctorinfos =
                doctorinfoMapper.consultationStatistics(request.getName(), empty?null:request.getDateRange().get(0),empty?null:request.getDateRange().get(1));
        PageInfo<SysDoctorinfo> doctorInfos = new PageInfo<>(sysDoctorinfos);
        return sysDoctorinfos == null ? AjaxResult.error("暂无数据") : AjaxResult.success("获取会诊统计",doctorInfos);
    }
}




